<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/9/19
  Time: 9:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="<c:url value='/js/jquery-1.8.2.js'/>"></script>
</head>
<script>
    $().ready(function () {
        var msg = '${msg}';
        if(msg!=null&&msg!=""){
            $("#aa").html(msg);
        }
        setTimeout(function () {
            $("#aa").html("");
        },3000)
    });
</script>
<body>
    <script>
        function getlist(obj) {
            location.href="<c:url value='/goodsServlet?method=list&sortid='/>"+obj.value;
        }
    </script>
    <center>
        <tr align="center">
            <td colspan="100">
                请选择商品分类<select name="sortid" onchange="getlist(this)">
                                <option value="-1">全部</option>
                                <c:forEach items="${slist}" var="s">
                                    <option value="${s.sortid}" ${sortid==s.sortid?'selected':''}>${s.sname}</option>
                                </c:forEach>
                            </select>
            </td>
        </tr>
        <table>
            <tr align="center" bgcolor="gray">
                <th>
                    商品编号
                </th>
                <th>商品名称
                </th>
                <th>商品分类
                </th>
                <th>
                    商品产地
                </th>
                <th>生产日期</th>
                <th>单价</th>
                <th>剩余数量</th>
                <th>购买</th>
            </tr>
            <c:forEach varStatus="aa" items="${list}" var="g">
                <tr bgcolor="${aa.index%2==0?'gray':''}" align="center">
                    <td>${g.id}</td>
                    <td>${g.name}</td>
                    <td>${g.sname}</td>
                    <td>${g.address}</td>
                    <td>${g.createdate}</td>
                    <td>${g.price}</td>
                    <td>${g.remaining}</td>
                    <td><a href="<c:url value='/goodsServlet?method=tobuy&id=${g.id}'/>">购买</a></td>
                </tr>
            </c:forEach>
            <tr align="center">
                <td colspan="100" id="aa" style="color: red">

                </td>
            </tr>
        </table>
    </center>
</body>
</html>
